/**
 *  @file friendlyShip.cpp
 *
 *  @date 16-nov-2009
 *  @author Ives van der Flaas
 */

#include "friendlyShip.h"
#include "circularBoundingBox.h"

namespace si
{

FriendlyShip::FriendlyShip():
	Ship(	30, // starthealth
			si::Vector2(0.7, 0.7)), // virtual size
	fScore(0)
{
	// Center the ship in the middle of the screen
	fStartPosition = si::Vector2(-fVirtualSize.getX()/2,-2.1);

	fBoundingBox = std::tr1::shared_ptr<si::BoundingBox>(
			new CircularBoundingBox(fStartPosition-fVirtualSize/2, fVirtualSize.getX()/2));
}

FriendlyShip::~FriendlyShip()
{
	// TODO Auto-generated destructor stub
}

void FriendlyShip::reset()
{
	Ship::reset();
	fHealth = fStartHealth;
	fController->setPosition(fStartPosition);
}

void FriendlyShip::update(double time)
{
	Ship::update(time);

	fBoundingBox->setCenter(
					si::Vector2(
							fController->getPosition().getX()+fVirtualSize.getX()/2,
							fController->getPosition().getY()-fVirtualSize.getY()/2));

	fScoreKeeper->update(fScore);
}

void FriendlyShip::draw() const
{
	Ship::draw();

	fScoreKeeper->draw();
}

void FriendlyShip::takeHit(int hitAmount)
{
	Ship::takeHit(hitAmount);

	fScore -= 150;
}
void FriendlyShip::bulletHit(int whichBullet)
{
	Ship::bulletHit(whichBullet);

	fScore += 50;
}

void FriendlyShip::fire()
{
	Ship::fire();

	fScore--;
}
}
